Skip to content

Update multi-site redirect caching#358

Open
OscarBarrett wants to merge 1 commit into
nystudio107:develop-v5from
OscarBarrett:fix/redirect-multi-site-caching
Open

Update multi-site redirect caching#358
OscarBarrett wants to merge 1 commit into
nystudio107:develop-v5from
OscarBarrett:fix/redirect-multi-site-caching

Conversation

@OscarBarrett

@OscarBarrett OscarBarrett commented May 6, 2026

Copy link
Copy Markdown

Description

  • Ensure a redirect applies to a site before returning it
  • Delete redirects from cache if they do not apply to the site in the request
  • Added warnings for fail cache deletions or redirects that were attempted but should not have been applied for a site
  • Added unit tests

Running tests locally:

$ XDEBUG_MODE=coverage composer test
Codeception PHP Testing Framework v5.3.5 https://stand-with-ukraine.pp.ua

Unit Tests (5) ----------------------------------------------------------------------------------------------------
✔ BaseUnitTest: Plugin instance (0.01s)
✔ BaseUnitTest: Craft edition (0.00s)
✔ RedirectsServiceCacheTest: Save redirect to cache uses explicit site partition (0.01s)
✔ RedirectsServiceCacheTest: Find redirect match ignores cache entry for different site (0.01s)
✔ RetourUnitTest: Sanitize url (0.01s)
-------------------------------------------------------------------------------------------------------------------


Code Coverage Report:       
  2026-05-06 05:50:15       
                            
 Summary:                   
  Classes:  0.00% (0/6)     
  Methods:  4.92% (3/61)    
  Lines:   15.24% (181/1188)

nystudio107\retour\helpers\Text
  Methods:   0.00% ( 0/ 3)   Lines:  33.33% (  6/ 18)
nystudio107\retour\helpers\UrlHelper
  Methods:   0.00% ( 0/ 5)   Lines:  25.86% ( 15/ 58)
nystudio107\retour\services\Redirects
  Methods:  10.00% ( 3/30)   Lines:  22.50% (160/711)
Remote CodeCoverage reports are not printed to console

XML report generated in coverage.xml
Time: 00:15.267, Memory: 168.50 MB

OK (5 tests, 15 assertions)

Related issues

#357

- Ensure a redirect applies to a site before returning it
- Delete redirects from cache if they do not apply to the site in the request
- Added warnings for fail cache deletions or redirects that were attempted but should not have been applied for a site
- Added unit tests
@OscarBarrett OscarBarrett requested a review from khalwat as a code owner May 6, 2026 15:12
@khalwat

khalwat commented May 7, 2026

Copy link
Copy Markdown
Contributor

Very cool, will review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants